export default async (params) => {
  const { url, username, styleId, accessToken, tk, layer, maximumLevel } = params

  switch (params.type) {
    case 'mapbox':
      return new GC.MapboxStyleImageryProvider({
        url: 'https://api.mapbox.com/styles/v1',
        username,
        styleId,
        accessToken,
        scaleFactor: true
      })
    case 'tianditu':
      return new GC.WebMapTileServiceImageryProvider({
        url: `http://t3.tianditu.com/${layer}_w/wmts?tk=${tk}&service=wmts&request=GetTile&version=1.0.0&LAYER=${layer}&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles`,
        layer: 'tdtVecBasicLayer',
        style: 'default',
        format: 'image/jpeg',
        tileMatrixSetID: 'tiandituImgMarker',
        show: true,
        maximumLevel
      })
    case 'arcgis':
      return await GC.ArcGisMapServerImageryProvider.fromBasemapType(
        GC.ArcGisBaseMapType.SATELLITE // HILLSHADE OCEANS
      )
    case 'custom':
      return new GC.UrlTemplateImageryProvider({
        url,
        maximumLevel
      })
    case 'tianditu_note':
      return new GC.WebMapTileServiceImageryProvider({
        url: `http://t0.tianditu.com/cia_w/wmts?tk=${tk}&service=wmts&request=GetTile&version=1.0.0&LAYER=cia&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles`,
        layer: 'tiandituImgMarker',
        style: 'default',
        format: 'image/jpeg',
        tileMatrixSetID: 'tiandituImgMarker',
        show: true,
        maximumLevel
      })
    default:
      break
  }
}
